/******************* 公共变量 *******************/
var type = core.getUrlData('type');

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: '.wrap',
	data: {
		password: '',
		newPassword: '',
		btnJudge: true
	},
	methods: {
		checkPw: function (event) {
			var $this = $(event.target),
				thisIndex = $this.parent().index(),
				thisVal = $this.val();

			if (thisVal) {
				if (core.pwJudge(thisVal)) {
					if (this.password == this.newPassword) {
						core.layerHint('新旧密码不可一致');
					}
				} else {
					core.layerHint('请输入6-16位，字母或数字密码');
				}
			} else {
				core.layerHint('输入密码不可为空');
			}
		},
		submit: function () {
			var _this = this;
			if (core.pwJudge(this.password)) {
				if (core.pwJudge(this.newPassword)) {
					if (this.password != this.newPassword) {
						if (this.btnJudge) {
							this.btnJudge = false;
							$.ajax({
								url: userPwUrl,
								type: 'post',
								data: {
									password: this.password,
									password1: this.newPassword,
									password2: this.newPassword
								},
								success: function (data) {
									console.log(data)
									
									setTimeout(function () {
										_this.btnJudge = true;
									}, 1000);
									if (data.result == 1) {
										core.hintBack(data.message);
									} else {
										core.layerHint(data.message);
									}
								}
							});
						}
					} else {
						core.layerHint('新旧密码不可一致');
					}
				} else {
					core.layerHint('请输入6-16位，字母或数字密码');
				}
			} else {
				core.layerHint('请输入6-16位，字母或数字密码');
			}
		}
	},
	computed: {
		
	},
	components: {
		
	},
	created: function () {
		
	},
	mounted: function () {
		common.bindBack();
	},
	updated: function () {
		
	}
});